package org.mspring.mlog.dao.impl;

import java.util.List;

import org.mspring.mlog.dao.LinkTypeDao;
import org.mspring.mlog.entity.LinkType;
import org.mspring.platform.dao.hibernate.GenericDao;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Gao Youbo
 * @since 2014-01-11
 */
@Repository
public class LinkTypeDaoImpl extends GenericDao<LinkType, Long> implements LinkTypeDao {

    @Override
    public List<LinkType> listVisables() {
        return super.list("select lt from LinkType lt where lt.visable = ? order by lt.sort asc", true);
    }

    @Override
    public void updateLinkTypeName(long id, String name) {
        super.executeUpdate("update LinkType lt set lt.name = ? where lt.id = ?", name, id);
    }

    @Override
    public void updateLinkTypeSort(long id, long sort) {
        super.executeUpdate("update LinkType lt set lt.sort = ? where lt.id = ?", sort, id);
    }

    @Override
    public void updateLinkTypeVisable(long id, boolean visable) {
        super.executeUpdate("update LinkType lt set lt.visable = ? where lt.id = ?", visable, id);
    }

}
